#ifndef __SINGLETON_H__
#define __SINGLETON_H__

#include <stdlib.h>
#include <algorithm>


template<class T>

class Singleton
{
public:
    virtual	 ~Singleton();
    
    static T* ptr(void);
    static T& ref(void);
    
protected:
    Singleton();
};

template <class T>
Singleton<T>::Singleton(){
}


template <class T>
Singleton<T>::~Singleton(){
}

template <class T>
T* Singleton<T>:: ptr(void)
{
    return &(ref());
}


template <class T>
T& Singleton<T>::ref(void){
    static T instance;
    return instance;
}


#endif /* __SINGLETON_H__ */